package osSRC.banker;

import java.util.*;

public class Request {
	int PID;
	int resourceKindCount;
	int[] request;
	Request(){}
	Request(Banker banker){
		Scanner scanner=new Scanner(System.in);
		while (true){
			try{
				this.resourceKindCount= banker.getResourceKindCount();
				this.request=new int[banker.getProcessCount()];
				System.out.println("PID of the process requesting resources:");
				PID=scanner.nextInt();
				if(PID<=0||PID> banker.getProcessCount()){
					System.out.println("There is no process with PID "+PID);
					continue;
				}
				System.out.println("Please enter the amount of the "
						+this.resourceKindCount
						+" resources requested");
				for(int i=0;i<this.resourceKindCount;i++){
					this.request[i]=Math.abs(scanner.nextInt());
				}
				break;
			}
			catch (InputMismatchException inputMismatchException){
				System.out.println("Please enter a NUMBER");
			}
		}

	}
}
